package component
{
	import flash.text.TextFieldAutoSize;
	
	import mx.controls.Button;
   
    public class MultiLinedButton extends Button
    {
    	public static var maxheight:int = 0;
    	public static var maxWidth:int = 0;
        public function MultiLinedButton()
        {
            super();
        }
       
        override protected function createChildren():void
        {
            super.createChildren();
           
            textField.multiline = true;
            textField.wordWrap = true;
            textField.autoSize = TextFieldAutoSize.CENTER;
        }
       
        override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
        {
            super.updateDisplayList(unscaledWidth, unscaledHeight);
            textField.y = (this.height - textField.height) >> 1;
            height = textField.height + getStyle("paddingTop") + getStyle("paddingBottom");
            if (height < this.minHeight) this.height = this.minHeight;
            
            if(this.height >= maxheight)
            {
            	maxheight = this.height;
            }
            else
            {
            	this.height = maxheight;
            }
            
        }
    }
}